package com.tron.dobest.java.tronangent;

/**
 * 静态代理示例
 */
public class SimpleStaticProxyDemo {

    interface IService {
        void sayHello();
    }

    static class RealService implements IService {
        @Override
        public void sayHello() {
            System.out.println("真实服务sayHello");
        }
    }

    static class TraceProxy implements IService {
        private RealService realService;

        public TraceProxy(RealService realService) {
            this.realService = realService;
        }

        @Override
        public void sayHello() {
            System.out.println("代理服务start");
            realService.sayHello();
            System.out.println("代理服务end");
        }
    }

    public static void main(String[] args) {
        TraceProxy traceProxy = new TraceProxy(new RealService());
        traceProxy.sayHello();
    }


}
